package com.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.dao.ClazzDao;
import com.dao.StudentDao;
import com.model.Clazz;
import com.model.ClazzProanswer;
import com.model.Paper;
import com.model.Student;
import com.service.ClazzService;
import com.util.Pagination;

@Component("ClazzService")
public class ClazzServiceImpl implements ClazzService {

    @Resource
    private ClazzDao clazzDao;

    @Resource
    private StudentDao studentDao;

    public ClazzDao getClazzDao() {
        return clazzDao;
    }

    public void setClazzDao(ClazzDao clazzDao) {
        this.clazzDao = clazzDao;
    }

    @Override
    public List<Clazz> ClazzList(Clazz clazz) {

        return clazzDao.ClazzList(clazz);
    }

    @Override
    public List<Student> getStudenListByClazzid(int id) {

        return clazzDao.getStuListByclazzid(id);
    }

    @Override
    public void addClazz(Clazz clazz) {
        clazzDao.addClazz(clazz);

    }

    @Override
    public Clazz findByclassnum(int classnum) {
        return clazzDao.findByClazznum(classnum);

    }

    @Override
    public void addStuList(List<Student> stuList) {
        for (Student stu : stuList) {
            clazzDao.addStudent(stu);
        }

    }

    @Override
    public List<Student> findByExample(Student stu) {

        return studentDao.findByExample(stu);
    }

    @Override
    public List<Paper> getStudentPapers(String id) {

        return studentDao.getStudentPapers(id);
    }

    @Override
    public List showScore(int sid) {

        return studentDao.showScore(sid);
    }

    @Override
    public Student editInfo(int sid ,String sno, String pas) {

        return studentDao.editInfo(sid ,sno, pas);
    }

    @Override
    public boolean checkNum(int num) {
        Clazz clazz = clazzDao.findByClazznum(num);
        if (clazz == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Student StuInfo(int id) {

        return clazzDao.StuInfo(id);
    }

    @Override
    public Student teaEditInfo(int sid, String pas, String stuname) {
        return clazzDao.teaEditInfo(sid, pas, stuname);

    }

    @Override
    public Clazz findByClazzId(int id) {
        return clazzDao.findClazzById(id);

    }

    @Override
    public void addStudent(Student student) {
        clazzDao.addStudent(student);

    }

    @Override
    public void delStudent(int id) {
        clazzDao.delStudent(id);

    }

    @Override
    public void delClazzById(int id) {
        clazzDao.delClazzById(id);

    }

    @Override
    public List<Student> checkNameExitByClazzid(Student stu, int id) {

        return clazzDao.checkNameExitByClazzid(stu, id);
    }

    @Override
    public Pagination StuScore(ClazzProanswer proanswer, Pagination paperPage, int id) {

        return clazzDao.StuScore(proanswer, paperPage, id);
    }

    @Override
    public List paperInfo(int uid, int pid) {

        return clazzDao.paperInfo(uid, pid);
    }

    @Override
    public List getPaperBycid(int id) {

        return clazzDao.getPaperBycid(id);
    }

	@Override
	public List<Clazz> getAllClazzList(String sno) {
		
		return clazzDao.getAllClazzList(sno);
	}

	@Override
	public List<Paper> getStudentPapers(int clazzid) {
		
		return clazzDao.getPaperBycid(clazzid);
	}

	@Override
	public Student getStu(String sno, String clazzid) {
		
		return clazzDao.getStu(sno, clazzid);
	}

	@Override
	public Student getStuBySnoPwd(String sno, String pwd) {
		return clazzDao.getStuBySNOPWD(sno,pwd);
	}

}
